﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;

namespace YJKAxisAndEdit
{
	public class ModelCurveFilter : ISelectionFilter
	{
		public ModelCurveFilter()
		{
		}

		public ModelCurveFilter(List<string> lineTypeName)
		{
			this.m_LineTypeName = lineTypeName;
		}

		public bool AllowElement(Element elem)
		{
			if (elem.GetType() == typeof(ModelLine))
			{
				if (this.m_LineTypeName.Count == 0)
				{
					return true;
				}
				ModelLine modelLine = elem as ModelLine;
				if (this.CompareName(modelLine.LineStyle.Name))
				{
					return true;
				}
			}
			else if (elem.GetType() == typeof(ModelArc))
			{
				if (this.m_LineTypeName.Count == 0)
				{
					return true;
				}
				ModelArc modelArc = elem as ModelArc;
				if (this.CompareName(modelArc.LineStyle.Name))
				{
					return true;
				}
			}
			else if (elem.GetType() == typeof(DetailLine))
			{
				if (this.m_LineTypeName.Count == 0)
				{
					return true;
				}
				DetailLine detailLine = elem as DetailLine;
				if (this.CompareName(detailLine.LineStyle.Name))
				{
					return true;
				}
			}
			else if (elem.GetType() == typeof(DetailArc))
			{
				if (this.m_LineTypeName.Count == 0)
				{
					return true;
				}
				DetailArc detailArc = elem as DetailArc;
				if (this.CompareName(detailArc.LineStyle.Name))
				{
					return true;
				}
			}
			return false;
		}

		private bool CompareName(string name)
		{
			foreach (string strB in this.m_LineTypeName)
			{
				if (name.CompareTo(strB) == 0)
				{
					return true;
				}
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ pos)
		{
			return false;
		}

		private List<string> m_LineTypeName = new List<string>();
	}
}
